package com.springboot.erp.controller;

import com.springboot.erp.common.CommonResult;
import com.springboot.erp.entity.JshMaterialCurrentStock;
import com.springboot.erp.entity.ProductInfo;
import com.springboot.erp.service.JshMaterialCurrentStockService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.apache.tomcat.jni.Address;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@RequestMapping("/material")
@Slf4j
public class MaterialController {
    @Resource
    private JshMaterialCurrentStockService jshCurrentService;
    @GetMapping("/{id}")
    public JshMaterialCurrentStock findById(@PathVariable Integer id)
    {
        return jshCurrentService.findById(id);
    }
    @PostMapping
    public CommonResult addOne(@RequestBody JshMaterialCurrentStock jshMaterialCurrentStock)
    {
        log.info("jshMaterialCurrentStock: {}", jshMaterialCurrentStock);
        jshCurrentService.insert(jshMaterialCurrentStock);
        return new CommonResult(0, "success", null);
    }
    @PutMapping
    public CommonResult updateOne(@RequestBody JshMaterialCurrentStock jshMaterialCurrentStock){
        log.info("updateOne: {}", jshMaterialCurrentStock);
        jshCurrentService.update(jshMaterialCurrentStock);
        return new CommonResult(0, "success", null);
    }
    @DeleteMapping("/{id}")
    public CommonResult deleteOne(@PathVariable Integer id) {
        log.info("删除库存记录，ID: {}", id);
        jshCurrentService.delete(id);
        return new CommonResult(0, "删除成功", null);
    }






}
